<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24" type="flex" align="middle">
          <a-col flex="450px">
            <a-form-item label="">
              <a-input-group compact>
                <a-select v-model="queryParam.searchField" @change="changeForceUpdate">
                  <a-select-option value="projectNo"> 项目编号 </a-select-option>
                  <a-select-option value="projectName"> 项目名称 </a-select-option>
                  <a-select-option value="projectManager"> 项目经理 </a-select-option>
                </a-select>
                <a-input-search
                  style="width: 78%"
                  v-model="queryParam.keyword"
                  @search="searchQuery"
                  placeholder="请按照关键字进行搜索"
                />
              </a-input-group>
            </a-form-item>
          </a-col>
          <a-col flex="150px">
            <year-picker :year="searchYear" @yearChange="yearChange"></year-picker>
          </a-col>
          <a-col flex="auto">
            <span class="flex-btn-line">
              <a-button type="primary" @click="showSearchForm = true" icon="search">高级查询</a-button>
              <a-button
                type="primary"
                @click="handlePostExportXls('项目节点及时率报工报表')"                
                icon="download"
                >导出</a-button
              >
              <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>

      <a-modal
        :visible="showSearchForm"
        width="70vw"
        :bodyStyle="{ padding: '10px' }"
        title="高级查询"
        @ok="handleToSearch"
        @cancel="showSearchForm = false"
      >
        <a-form-model ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol">
          <a-row :gutter="24">
            <a-col :span="8">
              <a-form-model-item label="项目编号">
                <a-input v-model="queryParam.projectNo" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目名称">
                <a-input v-model="queryParam.projectName" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目经理">
                <a-input v-model="queryParam.projectManager" />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-modal>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator"></div>
    <div class="container">
      <a-table
        ref="table"
        bordered
        size="middle"
        :rowKey="rowKey"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :rowSelection="{
          selectedRowKeys: selectedRowKeys,
          onChange: onSelectChange,
          onSelectAll: onSelectAll,
          columnWidth: 1,
        }"
        :loading="loading"
        :scroll="{ x: true }"
        @change="handleTableChange"
      >
      </a-table>
    </div>

    <!-- table区域-begin -->
  </a-card>
</template>


<script>
import { JeecgListMixin } from '@/mixins/JeecgListSearchMixin'
import { strNotNull, getParamValFromUrl } from '@/utils/common.js'
import moment from 'moment'
export default {
  name: 'NodeTimelinessRate',
  mixins: [JeecgListMixin],
  components: {
    YearPicker: () => import('@/components/tools/YearPicker'),
  },
  data() {
    return {
      description: '项目节点及时率报表',
      /* 勾选导出参数 */
      rowKey: 'strId',
      busType: 'NodeTimelinessRate',
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 5,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '项目编号',
          align: 'center',
          width: 55,
          dataIndex: 'projectNo',
        },
        {
          title: '项目名称',
          align: 'center',
          width: 80,
          dataIndex: 'projectName',
        },
        {
          title: '项目经理',
          align: 'center',
          width: 60,
          dataIndex: 'projectManager',
        },
        {
          title: '项目等级',
          align: 'center',
          width: 30,
          dataIndex: 'projectLevel',
        },
        {
          title: '计划验收投产完成日期',
          align: 'center',
          width: 60,
          dataIndex: 'timeLinessFinishDate',
        },
        {
          title: '实际验收投产完成日期',
          align: 'center',
          width: 60,
          dataIndex: 'realFinishDate',
        },
        {
          title: '验收节点逾期时间(天)',
          align: 'center',
          width: 30,
          dataIndex: 'overdueDays',
        },
        {
          title: '验收节点是否逾期',
          align: 'center',
          width: 30,
          dataIndex: 'beOverdue',
        },
        {
          title: '到期关键节点数',
          align: 'center',
          width: 25,
          dataIndex: 'expireNumsMain',
        },
        {
          title: '到期非关键节点数',
          align: 'center',
          width: 25,
          dataIndex: 'expireNums',
        },
        {
          title: '按时完成数',
          align: 'center',
          width: 25,
          dataIndex: 'onTimeNums',
        },
        {
          title: '逾期节点数',
          align: 'center',
          width: 25,
          dataIndex: 'beOverdueNums',
        },
        {
          title: '未到期节点数',
          align: 'center',
          width: 30,
          dataIndex: 'unExpireNums',
        },
        {
          title: '总计关键节点数',
          align: 'center',
          width: 40,
          dataIndex: 'totalMain',
        },
        {
          title: '总计非关键节点数',
          align: 'center',
          width: 40,
          dataIndex: 'totalAdd',
        },
        {
          title: '完成节点数',
          align: 'center',
          width: 40,
          dataIndex: 'totalCompletion',
        },
        {
          title: '关键节点完成数',
          align: 'center',
          width: 40,
          dataIndex: 'totalMainCompletion',
        },
        {
          title: '及时率(%)',
          align: 'center',
          width: 30,
          dataIndex: 'timeLinessRate',
        },
        {
          title: '节点进度占比(%)',
          align: 'center',
          width: 30,
          dataIndex: 'nodeProgressRate',
        },
      ],
      url: {
        list: '/projectReport/nodeTimelinessRate',
        exportXlsUrl: '/projectReport/nodeTimelinessRateExport',
      },
      showSearchForm: false,
      keyword: '',
      labelCol: { span: 8 },
      wrapperCol: { span: 15 },
      proYear: '',
      deptId: '',
      searchYear: '',
    }
  },
  mounted() {
    this.queryParam.searchField = 'projectNo'
    this.searchYear = moment().format('YYYY')
    this.queryParam.searchYear = this.searchYear
    this.proYear = getParamValFromUrl('proYear')
    this.deptId = getParamValFromUrl('deptId')
    if (strNotNull(this.deptId)) {
      this.queryParam.deptId = this.deptId
      this.columns.push({
        title: '统计部门',
        align: 'center',
        width: 40,
        dataIndex: 'deptNames',
      })
    }
    if (strNotNull(this.proYear)) {
      this.queryParam.proYear = this.proYear
      this.columns.push({
        title: '统计年份',
        align: 'center',
        width: 40,
        dataIndex: 'proYear',
      })
    }
    this.columns.push({
      title: '项目状态',
      align: 'center',
      width: 40,
      dataIndex: 'projectStatus',
    })
  },
  computed: {},
  methods: {
    yearChange(year) {
      this.searchYear = year
      this.queryParam.searchYear = year
      this.handleToSearch()
    },
    handleToSearch() {
      this.showSearchForm = false
      this.searchQuery()
    },
    searchReset() {
      this.queryParam = {}
      this.queryParam.searchField = 'projectNo'
      if (strNotNull(this.proYear)) {
        this.queryParam.proYear = this.proYear
      }
      if (strNotNull(this.deptId)) {
        this.queryParam.deptId = this.deptId
      }
      this.handleToSearch()
    },
  },
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/hte-main.less';
@media (max-width: 1170px) {
  .page-main .container section .list-content > div.flex-num1-box {
    flex-wrap: wrap;
    > div {
      &:nth-child(1),
      &:nth-child(2) {
        width: 48%;
      }
      &:nth-child(3) {
        width: 100%;
        justify-content: flex-start;
        > span {
          margin-right: 20px;
          margin-left: 0;
        }
      }
    }
  }
  .page-main .container section .list-content > div.flex-num2-box {
    display: block;
    margin-top: 0;
  }
}
</style>